﻿using BouncingBallGame.ViewModels.ShapeViewModels;
using System;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace BouncingBallGame.Helpers
{
    public class ShapeTemplateSelector : DataTemplateSelector
    {
        public DataTemplate CircleTemplate { get; set; }
        public DataTemplate PointTemplate { get; set; }
        public DataTemplate RectangleTemplate { get; set; }
        public DataTemplate LineSegmentTemplate { get; set; }
        public DataTemplate BallTemplate { get; set; }
        public DataTemplate GiftTemplate { get; set; }
        public DataTemplate ObstacleTemplate { get; set; }
        public DataTemplate FieldTemplate { get; set; }

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            ShapeViewModelBase drawableObject = (ShapeViewModelBase)item;

            if (drawableObject is ObstacleViewModel)
            {
                return this.ObstacleTemplate;
            }
            else if (drawableObject is GiftViewModel)
            {
                return this.GiftTemplate;
            }
            else if (drawableObject is FieldViewModel)
            {
                return this.FieldTemplate;
            }
            else if (drawableObject is BallViewModel)
            {
                return this.BallTemplate;
            }
            else if (drawableObject is RectangleViewModel)
            {
                return this.RectangleTemplate;
            }
            else if (drawableObject is PointViewModel)
            {
                return this.PointTemplate;
            }
            else if (drawableObject is CircleViewModel)
            {
                return this.CircleTemplate;
            }
            else if (drawableObject is LineSegmentViewModel)
            {
                return this.LineSegmentTemplate;
            }
            

            throw new ArgumentException("Not supported DrawableObjectBase type!", "item");
        }

    }
}
